//
// Created by jsjxsy on 2022/7/5.
// c primer plus 10.13 2练习提
//
#include <stdio.h>
//#include <io_utils.h>
void copy_arr(double target[], double source[], int size) {
  for (int i = 0; i < size; ++i) {
    target[i] = source[i];
  }
}

void copy_ptr(double *target, double *source, int size) {
  for (int i = 0; i < size; ++i) {
    *(target++) = *(source++);
  }
}

void copy_ptrs(double *target, double *source, double *end) {
  for (int i = 0; source < end; ++i) {
    *(target++) = *(source++);
  }
}

int main(void) {
  double source[5] = {1.1, 2.2, 3.3, 4.4, 5.5};
  double target1[5];
  double target2[5];
  double target3[5];
//  PRINT_DOUBLE_ARRAY(source, 5);
  copy_arr(target1, source, 5);
//  PRINT_DOUBLE_ARRAY(target1, 5);
  copy_ptr(target2, source, 5);
//  PRINT_DOUBLE_ARRAY(target2, 5);
  copy_ptrs(target3, source, source+5);
//  PRINT_DOUBLE_ARRAY(target3, 5);
  return 0;
}
